package com.xnyzc.lhy.mis.service.impl.punishment;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.mis.entity.punishment.*;
import com.xnyzc.lhy.mis.mapper.punishment.OaDUserPenaltyDetailMapper;
import com.xnyzc.lhy.mis.mapper.punishment.OaDUserPunishmentMapper;
import com.xnyzc.lhy.mis.service.punishment.IOaDUserPenaltyDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 违规司机详情表 服务实现类
 * </p>
 *
 * @author cuixiaojian
 * @since 2019-10-27
 */
@Service
public class OaDUserPenaltyDetailServiceImpl
    extends ServiceImpl<OaDUserPenaltyDetailMapper, OaDUserPenaltyDetail>
    implements IOaDUserPenaltyDetailService
{
    @Autowired
    OaDUserPenaltyDetailMapper oaDUserPenaltyDetailMapper;

    @Autowired
    OaDUserPunishmentMapper oaDUserPunishmentMapper;

    /**
     * 查询司机处罚信息详情
     */
    @Override
    public Rv queryOaDUserPenaltyDetail(Long driverId)
    {
        //司机基本信息
        OaDUserBasicInformation oaDUserBasicInformation =
                oaDUserPenaltyDetailMapper.selectDriverDetials(driverId);

        //司机违规记录
        List<OADUserWhetherPunishmentInfo> oaDUserWhetherPunishmentInfos =
                oaDUserPenaltyDetailMapper.queryDriversWhetherPunishment(driverId);

        //司机处罚记录
        List<OaDUserPunishedInfo> oaDUserPunishedInfoList =
                oaDUserPenaltyDetailMapper.queryDetailsDriverOffences(driverId);

        Map<String, Object> map = new HashMap<String, Object>();
        //司机基本信息
        map.put("oaDUserBasicInformation", oaDUserBasicInformation);
        //司机违规记录
        map.put("oaDUserWhetherPunishmentInfos", oaDUserWhetherPunishmentInfos);
        //司机处罚记录
        map.put("oaDUserPunishedInfoList", oaDUserPunishedInfoList);

        return Rv.wrap(EErrorCode.success, map);
    }

    @Override
    public Rv exportPunishmentRecord(Date startDate, Date endDate)
    {
        List<OaDUserPunishment> oaDUserPunishmentLList = oaDUserPunishmentMapper.getPunishmentList(startDate, endDate);
        return Rv.wrap(EErrorCode.success, oaDUserPunishmentLList);
    }

    @Override
    public Rv exportDriverPunished(Date startDate, Date endDate)
    {
        List<OaDUserPenaltyDetail> oaDUserPenaltyDetailLList = oaDUserPenaltyDetailMapper.getUnPunishmentList(startDate, endDate);
        return Rv.wrap(EErrorCode.success, oaDUserPenaltyDetailLList);

    }
}
